<template>
	<BaseContainer>
		<aplid-base-crud ref="crud" class="w-100" v-bind="{ ...baseConfig, ...$attrs }">
			<template v-slot:batchName="{ row }">
				<el-button type="primary" plain>查看</el-button>
			</template>
			<template v-slot:menuColumn="{ row }">
				<el-button type="primary" v-if="showBtn(row)" text plain v-auth="baseConfig.auth.edit" @click="handleOperate('edit',row,'回访')">回访</el-button>
			</template>
		</aplid-base-crud>
	</BaseContainer>
</template>

<script setup>
import { baseConfig } from './config'
import { getStore } from '@/utils/store'

const crud = ref()
const userInfo = getStore('userInfo') || {}

const authAreaArr = [userInfo.authProvince, userInfo.authCity, userInfo.authArea, userInfo.authStreet, userInfo.authCommunity].filter(Boolean)

const showBtn = (row) => {
  const rowArea = [
    row.authProvince,
    row.authCity,
    row.authArea,
    row.authStreet,
    row.authCommunity
  ].filter(Boolean)

  return row.visitStatus != 1 && authAreaArr.slice(-1)[0] == rowArea.slice(-1)[0]
}
const handleOperate = (type, row, title) => {
  nextTick(() => {
    crud.value.handleOperate(type, row, title)
  })
}
</script>

<style lang="scss" scoped></style>
